<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';

if($_RQ['op']=='get'){
	//显示统计数据
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$order['all']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'status'=>3));
	$order['day']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'status'=>3,'createtime >'=>$daytime));
	$money['deduct']=pdo_getsum('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>0),'deduct');
	$money['backredpack']=pdo_getsum('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>2),'backredpack');
	$money['backmoney']=pdo_getsum('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>2),'backmoney');
	$money['day']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	
	$order['table']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>1));
	$order['out']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>2));
	$order['self']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>3));
	$order['yuyue']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>4));
	
	$money['table']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>1));
	$money['out']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>2));
	$money['self']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>3));
	$money['yuyue']=pdo_count('jy_weishop_coupon',array('uniacid'=>$_SESSION['uniacid'],'backtype'=>4));
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'总优惠券数据','datas'=>array(
			array('title'=>'总券数','num'=>1,'data'=>$order['all']),
			array('title'=>'立减券金额','num'=>1,'data'=>$money['deduct']),
			array('title'=>'返现券金额','num'=>1,'data'=>$money['backredpack']),
			array('title'=>'返余额券金额','num'=>1,'data'=>$money['backmoney']),
		)),
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'今日领取券数据','datas'=>array(
			array('title'=>'总券数','num'=>1,'data'=>$order['all']),
			array('title'=>'立减券金额','num'=>1,'data'=>$money['deduct']),
			array('title'=>'返现券金额','num'=>1,'data'=>$money['backredpack']),
			array('title'=>'返余额券金额','num'=>1,'data'=>$money['backmoney']),
		)),
		array('type'=>'echarts_pie','one_num'=>2,'width'=>'50%','ecid'=>'wechat','title'=>'券类型分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>array(
						array('name'=>'立减券','value'=>$order['table']),
						array('name'=>'返现券','value'=>$order['out']),
						array('name'=>'返余额券','value'=>$order['self']),
						array('name'=>'返积分券','value'=>$order['yuyue']),
					),
		)),
		array('type'=>'echarts_pie','one_num'=>2,'width'=>'50%','ecid'=>'wxapp','title'=>'购物/充值券分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>array(
						array('name'=>'购物优惠券','value'=>$money['table']),
						array('name'=>'充值优惠券','value'=>$money['table']),
					),
		)),
	);
	$return=array('htmls'=>$htmls);
	exi($return);
}